/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ixj.online.process;

import java.io.IOException;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;

/**
 *
 * @author Administrator
 */
public class CustomerSAXHandlerTest {

    public static void main(String[] args) {
        try {
            String xmlFile = "customers.xml";

            //
            SAXParserFactory saxFactory = SAXParserFactory.newInstance();
            SAXParser saxParser = saxFactory.newSAXParser();

            //
            CustomerSAXHandler customerSAXHandler = new CustomerSAXHandler();

            //
            saxParser.parse(xmlFile, customerSAXHandler);

            //
            List<Customer> listCustomer = customerSAXHandler.getListCustomer();

            System.out.println("Number of customer: " + listCustomer.size());
            for (Customer customer : listCustomer) {
                System.out.println("ID: " + customer.getId());
                System.out.println("First name: " + customer.getFirstName());
            }

        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (ParserConfigurationException ex) {
            ex.printStackTrace();
        } catch (SAXException ex) {
            ex.printStackTrace();
        }

    }
}
